{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## CSV导入File GDB\n",
    "python版本：2.7\n",
    "\n",
    "核心第三方包：arcpy\n",
    "\n",
    "数据：\n",
    "- [pois.txt](./pois.txt): 陕西省内旅游景点数据，坐标系4326 (经度字段：lng，维度字段：lat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import arcpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def CreateGDB(dir, gdbName):\n",
    "    gdb = os.path.join(dir, gdbName + \".gdb\")\n",
    "    if not os.path.exists(gdb):\n",
    "        arcpy.CreateFileGDB_management(dir, gdbName + \".gdb\")\n",
    "    print (\"GDB Created, Path: {0}\".format(gdb))\n",
    "    return gdb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GDB Created, Path: .\\data_nb.gdb\n"
     ]
    }
   ],
   "source": [
    "arcpy.env.workspace = CreateGDB(\".\",\"data_nb\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "sr = arcpy.SpatialReference(4326)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "csvpath = \"./pois.txt\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " [创建 XY 事件图层工具](http://desktop.arcgis.com/zh-cn/arcmap/latest/tools/data-management-toolbox/make-xy-event-layer.htm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Result 'temp'>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arcpy.MakeXYEventLayer_management(\n",
    "    csvpath, \"lng\", \"lat\", \"temp\", arcpy.SpatialReference(4326))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Result '.\\\\data_nb.gdb\\\\imported_poi'>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arcpy.CopyFeatures_management(\"temp\", \"imported_poi\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Result 'true'>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arcpy.Delete_management(\"temp\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[u'imported_poi']\n"
     ]
    }
   ],
   "source": [
    "print(arcpy.ListFeatureClasses())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = gpd.read_file(arcpy.env.workspace, layer=u\"imported_poi\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x148cd748>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlYAAACXCAYAAADXjhUnAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzA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JgTWg1sWDorAvY072/X011kK72yKg6ZuI+g+miESsREZEM2FBfR3Tv7ozv7zdd6pgptECoiIhIhoSn8Jt+2VjHdDORBUIVrERERETGMJFgpalAEREREY8oWImIiIh4RMFKRERExCMKViIiIiIe0TpWIiIiaaZv4c1cClYiIiJpNHJvvuWherraI2xr2MmWTWQsXCnoeUdTgSIiImk0vDdf3BfgN799lZfD7/LBQBEPPPzopF43HA7z3R/8kBs/v4Gla69lyVWfoO6WL7Fjx47zHretYSexYIjl9XcRC4bY1rCTcDg8qXpmKwUrERGRNGqNRInh55W39pMoqqR8yRXkLVzOs799fcJhZjgcvXHoBO8eTxJYdweFN3yNvo/eyP3bHztnuBq5CbPP76esqobgqvXsamya6D9xVlOwEhERSaOa6iCv79lDUUUNBcVzMZ8PN9hP5eLLJhxmhsPR22++RlntzZQu/hhziktJFJQRXPcFtj/yxLjHahNmbylYiYiIpNGG+joib75Isq+HZDLBqWMRTuz7F666rm7CYWY4HPV0n6QweAkAOYEAA4Mx5i/8KG3tneMeO7wJ80jahHniFKxERETSKBQK8am1l9G7/0WOPPsT3KHXufYTnyS/qHjCYWY4HBWXzKU3+gEA8ViMvNwAx48coKqybNxjtQmzt84brMysxsyeM7N9Zva2mf1pqn2+mT1jZu+lbkunvlwREZHs97WvbGbpwnJu/MJt1G38E/LyCycVZobD0corrqSz+Rd0HdxHf08X/tOdRF/5OV/f/KVxjw2FQmzZtJFANMz+xocIRMNs2bRR3wqcoPNuwmxmVUCVc+41MysG9gAbgLuA486575nZfUCpc+4753otbcIsIiIyxOslDoZf7/kXXuBQpB3n87N4URVf3/wlbrvtNg8rnz0msgnzeYPVGCd5EvjfqZ/rnXNtqfD1vHPu8nMdq2AlIiIi2WIiweqirrEys8XAWuAVYIFzrg0gdVs5zjF3m1mzmTV3dHRczOlEREREssoFByszKwJ+CvyZc677Qo9zzj3gnKt1ztVWVFRMpEYRERGRrHBBwcrMchkKVT9xzv0s1Xw0NQU4fB1W+9SUKCIiIpIdLuRbg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yTmb3hnPusc+5tM3sCeAeIA99wziVSx3wT+BXgBx50zr2dofJnux+Y2RqGhkoPAv8B4Fx9J5njnIvrvTPtLQB2mhkM/X/9qHOu0cxeBZ4ws68Ch4AvZrDGWc3MHgOuB8rN7DBwP/A9xu6fXwI3MXQR9GngK2kveJYbp7+u9/KzS1vaiIiIiHgkm6YCRURERKY1BSsRERERjyhYiYiIiHhEwUpERETEIwpWIiIiIh5RsBIRERHxiIKViIiIiEf+H0qD4ZlaeyaMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 720x720 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data.plot(figsize=(10, 10), alpha=0.5, edgecolor='k')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:arcpy10-7] *",
   "language": "python",
   "name": "conda-env-arcpy10-7-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
